<!-- 首页 -->
<template>
	<view class="">
		<!-- 标题 -->
		<shopro-navbar back-icon-color="#020202" :background="{ background: '#fff' }" @backHandler="goBack"
			:backTextStyle="{
        color: '#020202',
        fontSize: '36rpx',
        fontWeight: '400',
      }" :isBack="true">
			<view slot="content" class="u-flex nav-wrap" style="margin: auto">
				{{ title }}
			</view>
		</shopro-navbar>
		<view v-if="type != 1" style="background: #fff; padding: 5px;margin-bottom: 20rpx;">
			<u-search margin="15rpx 30rpx" placeholder="搜索" height="64" @custom="onSearch" @search="onSearch"></u-search>
		</view>
		<view class="goods-tits u-flex u-flex-nowrap" v-if="secondsCateList.length>0">
			<!-- <u-section title="产业项目" sub-title="更多"></u-section> -->
			<view class="u-flex u-row-center u-col-center second-item" v-for="(item,index) in secondsCateList" :class="activeChoose==index?'active':''" @click="chooseSecond(item,index)">
				{{item.name}}
			</view>
		</view>
		<view class="goods-tit" v-if="type!='5'">
			<!-- <u-section title="产业项目" sub-title="更多"></u-section> -->
			<view class="flex">名师</view>
		</view>
<!--		<view class="flex goods-box" v-if="type!='5'">-->
<!--			<view class="mt10 goods-item" v-if="list && list.length > 0" v-for="(item, index) in list"-->
<!--				@click="teacherdetail(item.id)">-->
<!--				<view class="bga box bg" style="text-align:center">-->
<!--					<image :src="item.image" mode="aspectFill" style="width: 170rpx;-->
<!--          height: 170rpx;-->
<!--          border-radius: 50%;"></image>-->
<!--					<view style="display: flex; align-items: center; line-height: 30px" class="f16">-->
<!--						<view class="lianghang c3" style="padding-right: 10px">-->
<!--							{{ item.name }}-->
<!--						</view>-->

<!--					</view>-->
<!--					<view class="f14 c6 lianghang">-->
<!--						<view class="goodsCont" v-html="item.desc"></view>-->
<!--					</view>-->
<!--				</view>-->
<!--			</view>-->
<!--		</view>-->
		<view class="moreContent flex goods-box"  v-if="type!='5'">
			<view  v-if="list && list.length > 0" v-for="(item, index) in list">
				<view class="moreList" @click="teacherdetail(item.id)">
					<image class="imgs" :src="item.image" mode="aspectFill"></image>
					<view class="u-flex u-flex-col u-row-around u-m-l-20">
						<view class="cent-bo-b-l u-m-b-10 u-ellipsis-1" style="width: 63vw;display: flex;justify-content: flex-start">
							<view style="color:#333;font-weight: bold">{{item.name}}</view>
							<!--									<view class="cent-bo-b-r u-m-l-20  u-ellipsis-1" style="color:#626161;font-weight: normal">{{item.job}}</view>-->
						</view>
						<view class="u-ellipsis-2" style="width: 59vw;" v-html="item.desc"></view>
					</view>
				</view>
			</view>
		</view>
		<view class="goods-tit">
			<!-- <u-section title="产业项目" sub-title="更多"></u-section> -->
			<view class="flex">公司</view>
		</view>
		<view class="flex goods-box">
			<view class="mt10 goods-item" v-if="gongsilist && gongsilist.length > 0" v-for="(item, index) in gongsilist"
				@click="goodsdetail(item.id)">
				<view class="bga box bg" style="text-align:center">
					<image :src="item.image" mode="aspectFill" style="width: 170rpx;
          height: 170rpx;
          border-radius: 50%;"></image>
					<view style="display: flex; align-items: center; line-height: 30px" class="f16">
						<view class="lianghang c3" style="padding-right: 10px">
							{{ item.project_name }}
						</view>

					</view>
					<view class="f14 c6 lianghang">
						<view class="goodsCont" v-html="item.project_content"></view>
					</view>
				</view>
			</view>
		</view>

		<!-- <view style="text-align: center" class="xm" @click="handleJect">
      <view>
        <image
          src="@/static/xm.png"
          style="width: 30px; height: 30px; margin-top: 15px"
          mode=""></image>
      </view>
      我有项目
    </view> -->
		<!-- <u-sticky>
			
		</u-sticky> -->
	</view>
</template>

<script>
	import {
		mapMutations,
		mapActions,
		mapState,
		mapGetters
	} from "vuex";
	import {
		BASE_URL
	} from "@/env";
	export default {
		data() {
			return {
				type: "",
				enable: false, //是否开启吸顶。
				isConnected: true, //是否有网
				showPrivacy: false, //协议
				scrollTop: 0,
				id: "",
				list: [],
				gongsilist: [],
				title: "",
				base_url: BASE_URL,
				activeChoose:'null',
				secondsCateList:[],
				searchval:''
			};
		},
		onLoad(options) {
			console.log(options, "title");
			this.id = options.id;
			this.type = options.type;
			this.title = uni.getStorageSync("project_name");
			this.getSecondsCateList();
			this.getList()
			this.getGongsiList()
		},

		onShow() {
		},
		computed: {
			...mapGetters(["userInfo"]),
		},

		methods: {
			getSecondsCateList() {
				let data = {
					pid: this.id,
				}
				console.log(data, 'data')
				this.$new_http("finance.menu", data).then((res) => {
					console.log(res, 'list')
					if (res.code === 1) {
						this.secondsCateList = res.data;
					}
				});
			},
			getList() {
				let data = {
					cate_id: this.seconId?this.seconId:this.id,
					// type: 0,
					search: this.searchval ? this.searchval : "",
				};
				console.log(data, "data");
				this.$new_http("finance.teachlist", data).then((res) => {
					console.log(res, "list");
					if (res.code === 1) {
						this.list = res.data.data;
					}
				});
			},
			getGongsiList() {
				let data = {
					cate_id: this.seconId?this.seconId:this.id,
					search: this.searchval ? this.searchval : "",
				};
				this.$new_http("finance.gongsilist", data).then((res) => {
					console.log(res, "list");
					if (res.code === 1) {
						this.gongsilist = res.data.data;
					}
				});

			},
			chooseSecond(e,index){
				this.seconId = e.id;
				this.activeChoose = index;
				this.loadingType = 'more'
				this.page = 1;
				this.list = [];
				console.log("=====this.seconId",this.seconId)
				this.getList();
				this.getGongsiList()
			},
			onSearch(e) {
				console.log(e);
				this.searchval = e;
				this.getList(e);
				this.getGongsiList(e)
			},
			handleJect() {
				uni.navigateTo({
					url: "/pages/index/projectProp/index?isvip=" +
						this.userInfo.is_vip +
						"&type=" +
						0,
				});
			},
			goodsdetail(e) {
				uni.navigateTo({
					url: "/pages/finance/companyDetail?val=" + e,
				});
			},
			teacherdetail(e) {
				uni.navigateTo({
					url: "/pages/finance/teacherDetail?val=" + e,
				});
			},
			profav(id) {
				uni.request({
					url: this.base_url + '/api/info/profav',
					method: "POST",
					header: {
						"Content-Type": "application/json",
						token: uni.getStorageSync("token"),
					},
					data: {
						project_id: id,
					},
					success: (res) => {
						console.log(res);
						if (res.data.code == 1) {
							this.getList();
						} else {
							uni.showToast({
								title: res.data.msg,
								icon: "none",
							});
						}
					},
					fail: () => {},
					complete: () => {},
				});
			},
		},
	};
</script>

<style scoped lang="scss">
	.xm {
		width: 70px;
		height: 70px;
		background: linear-gradient(180deg, #f7bb42 0%, #ed861f 100%);
		box-shadow: 0px 0px 8px 0px rgba(131, 86, 37, 0.2);
		position: fixed;
		bottom: 80px;
		right: 10px;
		font-size: 12px;
		color: #fff;
		z-index: 1;
		border-radius: 50%;
	}

	.lianghang {
		text-align: center;
		width: 100%;
	}

	.xm image {
		width: 20px !important;
		height: 20px !important;
	}

	.goods-tit {
		display: flex;
		align-items: center;
		justify-content: space-between;
		background: #fff;
		padding: 30rpx;
	}
	.goods-tits{
		background: #fff;
		padding: 30rpx 0;
		overflow-x: scroll;
		.second-item{
			padding: 10rpx 20rpx;
			color:#333333;
			min-width: 156rpx;
		}
		.active{
			color: #faae0c;
			position: relative;
			&:after{
				content: "";
				position: absolute;
				bottom: -8rpx;
				width: 50%;
				height: 4rpx;
				background: #faae0c;
			}
		}
	}
	.goods-box {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		padding: 0 30rpx;
		background: #fff;
	}

	.goods-item {
		box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(0, 0, 0, 0.12);
		padding: 20rpx;
		border-radius: 20rpx;
		width: 48%;
		box-sizing: border-box;
		margin-bottom: 30rpx;
	}

	.goodsCont {
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 3;
		-webkit-box-orient: vertical;
	}

	.c3 {
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
	}
	.moreContent {
		
		.moreList {
			width: 100%;
			padding: 24rpx 10rpx 24rpx 10rpx;
			background: #ffffff;
			border-radius: 16rpx;
			margin-top: 20rpx;
			display: flex;
			box-shadow: 0rpx 0rpx 8rpx 0rpx rgba(0,0,0,0.12);
			.imgs {
				width: 170rpx;
				height: 170rpx;
				border-radius: 20rpx;
			}
			
			.moreRight {
				width: 431rpx;
				margin-left: 28rpx;
				
				.companyType {
					display: -webkit-box;
					overflow: hidden;
					text-overflow: ellipsis;
					word-break: break-all;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 3;
				}
				
				.name {
					font-family: PingFang;
					font-weight: bold;
					font-size: 32rpx;
					color: #000000;
				}
				
				.hite {
					margin-top: 20rpx;
					font-family: PingFang;
					font-weight: 500;
					font-size: 28rpx;
					color: #666666;
					line-height: 42rpx;
					display: -webkit-box;
					-webkit-box-orient: vertical;
					-webkit-line-clamp: 2;
					overflow: hidden;
					text-overflow: ellipsis;
				}
			}
		}
	}
</style>